float vignette(vec2 pos, float inner, float outer)
{
  float r = length(pos);
  r = 1.0 - smoothstep(inner, outer, r);
  return r;
}

// radial blur
//vec4 radial(sampler2D tex,
//              vec2 texcoord,
//              int samples,
//             float startScale = 1.0,
//              float scaleMul = 0.9)
//{
//    vec4 c= vec4(0.0);
//    float scale = startScale;
//    for(int i=0; i<samples; i++) {
//        vec2 uv = ((texcoord-0.5)*scale)+0.5;
//        vec4 s = texture2D(tex, uv);
//        c += s;
//        scale *= scaleMul;
//    }
//    c /= float(samples);
//    return c;
//}
//*
//            uniform sampler2D   starTex     : TEXUNIT2,
//            uniform sampler2D   starTex1    : TEXUNIT3,
//            uniform sampler2D   starTex2    : TEXUNIT4,*/
//uniform float       blurAmount; ////
//uniform float  effectAmount ; ////= 0.1
uniform float       exposure; ////           
//uniform vec2      windowSize ;
const vec3       gamma = vec3(0.5);
uniform sampler2D   sceneTex;
//uniform sampler2D   blurTex ;
void main()
{	      
	
    // sum original and blurred image
    vec4 scene = texture2D(sceneTex, gl_TexCoord[0].st);
    //vec4 blurred = texture2D(blurTex, gl_TexCoord[0].st);
	//vec4 effect = radial(blurTex, gl_TexCoord[0].st, 30, 1.0, 0.95);

    //vec4 c = mix(scene, blurred, blurAmount);
	//vec4 c=effect;
	//c += effect*effectAmount;
	//c += effect*0.1;

    // exposure
    //c = c * exposure;
	vec4 c = scene /8.0;
	//vec4 c = scene-vec4(5.0);
    
    // vignette effect
    c *= vignette(gl_TexCoord[0].st*2.0-1.0, 0.7, 1.5);

    // gamma correction
    c.rgb = pow(c.rgb, gamma);

    gl_FragColor=c;
	//gl_FragColor=scene;
}